<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学员信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-student-edit" th:object="${crmStudent}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">资源时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="resourceTime" th:value="${#dates.format(crmStudent.resourceTime, 'yyyy-MM-dd HH:mm:ss')}" id="resource-time" class="form-control" placeholder="yyyy-MM-dd HH:mm" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">资源来源方式：</label>
                    <div class="col-sm-8">
                        <select name="resourceType" class="form-control" th:with="type=${@dict.getType('crm_resource_type')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{resourceType}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">渠道来源编码：</label>
                    <div class="col-sm-8">
                        <select name="resourceCode" class="form-control" th:with="type=${@dict.getType('crm_resource_code')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{resourceCode}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">来源用户：</label>
                    <div class="col-sm-8">
<!--                        <input name="resourceUserId" th:field="*{resourceUserId}" class="form-control" type="text">-->
                        <select id="resource-user" class="form-control select2-multiple">
<!--                            <option value=""></option>-->
                            <option value="">--请选择推广人员--</option>
                            <option th:each="user:${promotionList}" th:value="${user.userId}" th:text="${user.userName}" th:field="*{resourceUserId}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">学员评级：</label>
                    <div class="col-sm-8">
                        <select name="levelCode" class="form-control" th:with="type=${@dict.getType('crm_student_level')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{levelCode}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">销售类型：</label>
                    <div class="col-sm-8">
                        <select name="salesType" class="form-control" th:with="type=${@dict.getType('crm_sales_type')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{salesType}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">销售人员：</label>
                    <div class="col-sm-8">
<!--                        <input name="salesmanId" th:field="*{salesmanId}" class="form-control" type="text">-->
                        <select id="salesman" class="form-control select2-multiple">
                            <option value="">--请选择销售人员--</option>
                            <option th:each="user:${salesmanList}" th:value="${user.userId}" th:text="${user.userName}" th:field="*{salesmanId}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input name="stuName" th:field="*{stuName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">手机号：</label>
                    <div class="col-sm-8">
                        <input name="stuMobile" th:field="*{stuMobile}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">固定电话：</label>
                    <div class="col-sm-8">
                        <input name="stuPhone" th:field="*{stuPhone}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">微信号：</label>
                    <div class="col-sm-8">
                        <input name="stuWechat" th:field="*{stuWechat}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">微信名：</label>
                    <div class="col-sm-8">
                        <input name="stuWechatName" th:field="*{stuWechatName}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">微信备注：</label>
                    <div class="col-sm-8">
                        <input name="stuWechatNote" th:field="*{stuWechatNote}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">QQ号：</label>
                    <div class="col-sm-8">
                        <input name="stuQq" th:field="*{stuQq}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">其他联系方式：</label>
                    <div class="col-sm-8">
                        <input name="stuOtherContact" th:field="*{stuOtherContact}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">学员省份：</label>
                    <div class="col-sm-8">
                        <input name="stuProvince" th:field="*{stuProvince}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">学员城市：</label>
                    <div class="col-sm-8">
                        <input name="stuCity" th:field="*{stuCity}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">学员地址：</label>
                    <div class="col-sm-8">
                        <input name="stuAddress" th:field="*{stuAddress}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">学员学历编码：</label>
                    <div class="col-sm-8">
                        <select name="stuEducationCode" class="form-control" th:with="type=${@dict.getType('crm_edu_code')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{stuEducationCode}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">毕业学校：</label>
                    <div class="col-sm-8">
                        <input name="stuCollege" th:field="*{stuCollege}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">客户需求：</label>
                    <div class="col-sm-10">
                        <textarea name="stuDamand" class="form-control" rows="6">[[*{stuDamand}]]</textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">备注：</label>
                    <div class="col-sm-10">
                        <textarea name="note" class="form-control">[[*{note}]]</textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-2 control-label">说明（内部）：</label>
                    <div class="col-sm-10">
                        <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">跟踪状态：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="followStatus" th:checked="${crmStudent.followStatus == '0' ? true : false}">
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/student";
        $("#form-student-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {

                var data = $("#form-student-edit").serializeArray();
                var resourceUserId = $.form.selectSelects("resource-user");
                var salesmanId = $.form.selectSelects("salesman");
                var followStatus = $("input[id='followStatus']").is(':checked') == true ? 0 : 1;

                data.push({"name": "resourceUserId", "value": resourceUserId});
                data.push({"name": "salesmanId", "value": salesmanId});
                data.push({"name": "followStatus", "value": followStatus});

                $.operate.save(prefix + "/edit", data)

                // $.operate.save(prefix + "/edit", $('#form-student-edit').serialize());
            }
        }

        // $("input[name='resourceTime']").datetimepicker({
        //     format: "yyyy-mm-dd hh:ii",
        //     // minView: "month",
        //     autoclose: true
        // });

        $(function() {

            <!-- laydate -->
            layui.use('laydate', function(){
                var laydate = layui.laydate;
                laydate.render({
                    elem: '#resource-time',
                    type: 'datetime',
                    trigger: 'click'
                });
            });

            $('#resource-user').select2({
                placeholder: "请选择推广人员",
                allowClear: true
            });

            $('#salesman').select2({
                placeholder: "请选择销售人员",
                allowClear: true
            });
        })
    </script>
</body>
</html>